//
//  RequestUtlity.m
//  RocketProject
//
//  Created by chen jiedan on 13-5-10.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "RequestUtlity.h"
#import "DeviceIdentifier.h"
#import "UIDevice-Hardware.h"

@implementation RequestUtlity

+ (NSString*)getFormattedUrl:(NSString *)aUrl
{
    NSString *ret = nil;
    
#ifdef DEBUG_URL_TEMP_SERVER
        //（1）qa环境
    ret = [NSString stringWithFormat:@"http://223.4.99.93/www.17ruyi.com/api.php?%@",aUrl];
#else
    ret = [NSString stringWithFormat:@"http://www.17ruyi.com/api.php?%@",aUrl];

#endif
    
    //h（屏幕高度）、w（屏幕宽度）、d（固定设备类型为iphone）、v（V1.3app系统版本，第一版默认都为1）、i（设备唯一id）, s（系统版本）, u (设备类型)
    //netTpye(网络请求的类型，wifi还是gps)、locEnabled(是否允许app使用定位服务)
    int width = 320;
    int height = 480;
    NSString *deviceFixedType       = @"iphone";
    
    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
    
//    NSString *deviceMac             = [DeviceIdentifier uniqueGlobalDeviceIdentifier];
    NSString *systemVersion         = [UIDevice currentDevice].systemVersion;
    NSString *deviceType            = [UIDevice currentDevice].platformString;//@"iphone 3gs"
    NSRange range = [ret rangeOfString:@"?"];
    
  
    if( range.length == 0 )
    {
        ret = [NSString stringWithFormat:@"%@?w=%d&h=%d&d=%@&v=%@&s=%@&u=%@",
                   ret, width,height,deviceFixedType,version,systemVersion,deviceType];
    }else{
        ret = [NSString stringWithFormat:@"%@&w=%d&h=%d&d=%@&v=%@&s=%@&u=%@",
                   ret, width,height,deviceFixedType,version,systemVersion,deviceType];
    }
    return ret;
}

@end
